use serde::Deserialize;
use serde::Serialize;
use ts_rs::TS;
use yata::core::PeriodType;
use yata::core::ValueType;

use super::IndicatorActionWrap;

///
/// Struct to hold the results of Struct yata::indicators::KnowSureThing

///
///  参见[KST](https://en.wikipedia.org/wiki/KST_oscillator)
///
#[derive(Serialize, Deserialize, Default, Debug, TS, Clone)]
#[ts(export)]
pub struct KST {
    ///  1 signal
    ///When KST crosses Signal line upwards, returns full buy signal.
    /// When KST crosses Signal line downwards, returns full sell signal.
    /// Otherwise returns no signal.
    pub signal0: Option<IndicatorActionWrap>,

    ///2 values
    ///KST value
    ///Range in (-inf; +inf)
    pub kst: ValueType,
    ///
    ///Signal line value
    ///Range in (-inf; +inf)
    pub signal: ValueType,
}

/// Configuration
#[derive(Serialize, Deserialize, Debug, TS, Clone, Copy)]
#[ts(export)]
pub struct KSTConfig {
    ///period1: PeriodType
    ///ROC1 period. Default is 10.
    ///
    pub period1: PeriodType,

    ///period2: PeriodType
    ///ROC2 period. Default is 15.
    ///
    pub period2: PeriodType,

    ///period3: PeriodType
    ///ROC3 period. Default is 20.
    ///
    pub period3: PeriodType,

    ///period4: PeriodType
    ///ROC4 period. Default is 30.
    ///
    pub period4: PeriodType,

    ///ma1: M
    ///ROC1 moving average type. Default is SMA(10).
    ///
    pub ma1: PeriodType,

    ///ma2: M
    ///ROC2 moving average type. Default is SMA(10).
    ///
    pub ma2: PeriodType,

    ///ma3: M
    ///ROC3 moving average type. Default is SMA(10).
    ///
    pub ma3: PeriodType,

    ///ma4: M
    ///ROC4 moving average type. Default is SMA(15).
    ///
    pub ma4: PeriodType,

    ///§signal: M
    ///Signal line moving average type. Default is SMA(9).
    pub signal: PeriodType,
}

impl Default for KSTConfig {
    fn default() -> Self {
        Self {
            period1: 10,
            period2: 15,
            period3: 20,
            period4: 30,
            ma1: 10,
            ma2: 10,
            ma3: 10,
            ma4: 15,
            signal: 9,
        }
    }
}
